/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ParentClass.java
 *
 * Created on 05 14, 11, 10:33:25 PM
 */
package vera;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author kasia
 */
public class ParentClass extends javax.swing.JFrame implements ActionListener {

    /** Creates new form ParentClass */
    public ParentClass() {
        initComponents();
        m_menuBar.getMenuItemVeraLogOut().addActionListener(this);
        m_menuBar.getMenuItemVeraExit().addActionListener(this);
        
        m_menuBar.getMenuItemBillCreate().addActionListener(this);
        m_menuBar.getMenuItemBillUpdate().addActionListener(this);
        m_menuBar.getMenuItemBillCancel().addActionListener(this);
        m_menuBar.getMenuItemBillSearch().addActionListener(this);
        m_menuBar.getMenuItemBillPrint().addActionListener(this);
        
        m_menuBar.getMenuItemReceiptCreate().addActionListener(this);
        m_menuBar.getMenuItemReceiptUpdate().addActionListener(this);
        m_menuBar.getMenuItemReceiptCancel().addActionListener(this);
        m_menuBar.getMenuItemReceiptSearch().addActionListener(this);
        m_menuBar.getMenuItemReceiptPrint().addActionListener(this);
        m_menuBar.getMenuItemReceiptVariance().addActionListener(this);
        
        m_menuBar.getMenuItemReportRealTime().addActionListener(this);
        m_menuBar.getMenuItemReportPrevious().addActionListener(this);
        
        m_menuBar.getMenuItemClientAdd().addActionListener(this);
        m_menuBar.getMenuItemClientUpdate().addActionListener(this);
        m_menuBar.getMenuItemClientSearch().addActionListener(this);
        
        m_menuBar.getMenuItemHelpHelp().addActionListener(this);
        m_menuBar.getMenuItemHelpAbout().addActionListener(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        m_menuBar = new vera.MenuBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("VERA"); // NOI18N

        m_menuBar.setName("m_menuBar"); // NOI18N
        setJMenuBar(m_menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1000, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 598, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ParentClass().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private vera.MenuBar m_menuBar;
    // End of variables declaration//GEN-END:variables

    public void actionPerformed(ActionEvent e) {
        String actionCommand = e.getActionCommand();
        
        this.setVisible(false);
        this.dispose();
        
        if (actionCommand.equalsIgnoreCase(Constants.LOGOUT)) {
            
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.EXIT)) {
            
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.CREATE_BILL)) {
            new BillScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.UPDATE_BILL)) {
            new BillScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.CANCEL_BILL)) {
            new BillScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.SEARCH_BILL)) {
            new SearchBill().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.PRINT_BILL)) {
            new BillScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.CREATE_RECEIPT)) {
            new ReceiptScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.UPDATE_RECEIPT)) {
            new ReceiptScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.CANCEL_RECEIPT)) {
            new ReceiptScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.SEARCH_RECEIPT)) {
            new SearchReceipt().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.PRINT_RECEIPT)) {
            new ReceiptScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.ADD_VARIANCE)) {
            new VarianceScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.REALTIME_REPORT)) {
            new ReportsScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.PREVIOUS_REPORT)) {
            new ReportsScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.ADD_CLIENT)) {
            new ClientScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.UPDATE_CLIENT)) {
            new ClientScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.SEARCH_CLIENT)) {
            new ClientScreen().setVisible(true);
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.HELP)) {
            
        }
        
        if (actionCommand.equalsIgnoreCase(Constants.ABOUT)) {
            
        }
            
            
//            Window w = (Window) this.getParent().getParent();
//            w.dispose();
//            new BillScreen().setVisible(true);
//            this.getParent().setVisible(false);
//            NewJPanel njp = new NewJPanel();
//            this.getParent().add(njp);
//            njp.setVisible(true);
//            this.setVisible(false);
//            this.dispose();
//            new BillScreen().setVisible(true);
//            this.removeAll();
//            this.getContentPane().add(new NewJPanel());
//            this.pack();
//            this.setVisible(true);
//            this.add(new NewJPanel());
    }
}
